package com.limf.demo.java5;

import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.Iterator;
import java.util.List;


public class Test1 {

	public static void main(String[] args) {
		List<User> alist = new ArrayList<User>();
		/*alist.add("123");
		alist.add("223");
		alist.add("323");
		alist.add("423");
		alist.add("523");
		alist.add("623");
		alist.add("723");*/
		Test1 test = new Test1();
		alist.add(new User("a1", "123"));
		alist.add(new User("a2", "124"));
		alist.add(new User("a3", "125"));
		alist.add(new User("a4", "126"));
		alist.add(new User("a5", "127"));
		
		
		try {
			test.printList(alist, null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		double balance = 55.5555;
		
		Formatter formatter = new Formatter();
		Formatter a = formatter.format("Remainning account$%.3f balance:$%.2f", balance, balance);
		System.out.println(a.toString());
		formatter.close();
	}
	
	public void printList(List<?> list, PrintStream out) throws IOException {
		
		for(Iterator<?> i = list.iterator(); i.hasNext();) {
			System.out.println(i.next().toString());
		}
		
	}

	
}

class User {
	
	private String userName;
	private String pwd;
	public User(String userName, String pwd) {
		super();
		this.userName = userName;
		this.pwd = pwd;
	}
	public String toString() {
		return userName + " , " + pwd;
	}
	
}